// @Date         2021-12-29
// @Author       Aaron Zhang
// @Description   
// @FileName      tracer.go   

package middlewares

import (
	"github.com/gin-gonic/gin"
	"zl-gin/utils"
)

//链路追踪
func Tracer(c *gin.Context) {
	//请求中是否存在
	tracer := utils.TraceHttpReq(c.Request)

	//嵌入到context
	tracer.InjectToContext(tracer, c)

	//嵌入到接下来的请求中
	req := tracer.InjectToHttp(c.Request)

	utils.GlobalTrace = tracer

	c.Request = req
}
